TASK 6
Other data set: https://archive.ics.uci.edu/ml/datasets/Air+quality • Explore data set, clean if needed • Explore each variable independently • Cross correlations • Build simple linear models with each predictor, check assumptions • For one of the models create train-test sets, plot the model, for the test set color real and predicted points differently; R^2 and p-value to title
df <- read.table("AirQualityUCI/AirQualityUCI.csv", sep = ";", header = T, dec = ",")
summary(df)
## Date Time CO.GT. PT08.S1.CO.
## : 114 00.00.00: 390 Min. :-200.00 Min. :-200
## 01/01/2005: 24 01.00.00: 390 1st Qu.: 0.60 1st Qu.: 921
## 01/02/2005: 24 02.00.00: 390 Median : 1.50 Median :1053
## 01/03/2005: 24 03.00.00: 390 Mean : -34.21 Mean :1049
## 01/04/2004: 24 04.00.00: 390 3rd Qu.: 2.60 3rd Qu.:1221
## 01/04/2005: 24 05.00.00: 390 Max. : 11.90 Max. :2040
## (Other) :9237 (Other) :7131 NA's :114 NA's :114
## NMHC.GT. C6H6.GT. PT08.S2.NMHC. NOx.GT.
## Min. :-200.0 Min. :-200.000 Min. :-200.0 Min. :-200.0
## 1st Qu.:-200.0 1st Qu.: 4.000 1st Qu.: 711.0 1st Qu.: 50.0
## Median :-200.0 Median : 7.900 Median : 895.0 Median : 141.0
## Mean :-159.1 Mean : 1.866 Mean : 894.6 Mean : 168.6
## 3rd Qu.:-200.0 3rd Qu.: 13.600 3rd Qu.:1105.0 3rd Qu.: 284.0
## Max. :1189.0 Max. : 63.700 Max. :2214.0 Max. :1479.0
## NA's :114 NA's :114 NA's :114 NA's :114
## PT08.S3.NOx. NO2.GT. PT08.S4.NO2. PT08.S5.O3.
## Min. :-200 Min. :-200.00 Min. :-200 Min. :-200.0
## 1st Qu.: 637 1st Qu.: 53.00 1st Qu.:1185 1st Qu.: 700.0
## Median : 794 Median : 96.00 Median :1446 Median : 942.0
## Mean : 795 Mean : 58.15 Mean :1391 Mean : 975.1
## 3rd Qu.: 960 3rd Qu.: 133.00 3rd Qu.:1662 3rd Qu.:1255.0
## Max. :2683 Max. : 340.00 Max. :2775 Max. :2523.0
## NA's :114 NA's :114 NA's :114 NA's :114
## T RH AH X
## Min. :-200.000 Min. :-200.00 Min. :-200.0000 Mode:logical
## 1st Qu.: 10.900 1st Qu.: 34.10 1st Qu.: 0.6923 NA's:9471
## Median : 17.200 Median : 48.60 Median : 0.9768
## Mean : 9.778 Mean : 39.49 Mean : -6.8376
## 3rd Qu.: 24.100 3rd Qu.: 61.90 3rd Qu.: 1.2962
## Max. : 44.600 Max. : 88.70 Max. : 2.2310
## NA's :114 NA's :114 NA's :114
## X.1
## Mode:logical
## NA's:9471
##
##
##
##
##
dim(df)
## [1] 9471 17
df <- na.omit(df[, -c(1, 2, 16, 17)])
df[df == -200] <- NA
#for(i in 1:ncol(df)){
# df[is.na(df[,i]), i] <- mean(df[,i], na.rm = TRUE)
#}
summary(df)
## CO.GT. PT08.S1.CO. NMHC.GT. C6H6.GT.
## Min. : 0.100 Min. : 647 Min. : 7.0 Min. : 0.10
## 1st Qu.: 1.100 1st Qu.: 937 1st Qu.: 67.0 1st Qu.: 4.40
## Median : 1.800 Median :1063 Median : 150.0 Median : 8.20
## Mean : 2.153 Mean :1100 Mean : 218.8 Mean :10.08
## 3rd Qu.: 2.900 3rd Qu.:1231 3rd Qu.: 297.0 3rd Qu.:14.00
## Max. :11.900 Max. :2040 Max. :1189.0 Max. :63.70
## NA's :1683 NA's :366 NA's :8443 NA's :366
## PT08.S2.NMHC. NOx.GT. PT08.S3.NOx. NO2.GT.
## Min. : 383.0 Min. : 2.0 Min. : 322.0 Min. : 2.0
## 1st Qu.: 734.5 1st Qu.: 98.0 1st Qu.: 658.0 1st Qu.: 78.0
## Median : 909.0 Median : 180.0 Median : 806.0 Median :109.0
## Mean : 939.2 Mean : 246.9 Mean : 835.5 Mean :113.1
## 3rd Qu.:1116.0 3rd Qu.: 326.0 3rd Qu.: 969.5 3rd Qu.:142.0
## Max. :2214.0 Max. :1479.0 Max. :2683.0 Max. :340.0
## NA's :366 NA's :1639 NA's :366 NA's :1642
## PT08.S4.NO2. PT08.S5.O3. T RH
## Min. : 551 Min. : 221.0 Min. :-1.90 Min. : 9.20
## 1st Qu.:1227 1st Qu.: 731.5 1st Qu.:11.80 1st Qu.:35.80
## Median :1463 Median : 963.0 Median :17.80 Median :49.60
## Mean :1456 Mean :1022.9 Mean :18.32 Mean :49.23
## 3rd Qu.:1674 3rd Qu.:1273.5 3rd Qu.:24.40 3rd Qu.:62.50
## Max. :2775 Max. :2523.0 Max. :44.60 Max. :88.70
## NA's :366 NA's :366 NA's :366 NA's :366
## AH
## Min. :0.1847
## 1st Qu.:0.7368
## Median :0.9954
## Mean :1.0255
## 3rd Qu.:1.3137
## Max. :2.2310
## NA's :366
dim(df)
## [1] 9357 13
head(df) %>% knitr::kable()
| 2.6 |
1360 |
150 |
11.9 |
1046 |
166 |
1056 |
113 |
1692 |
1268 |
13.6 |
48.9 |
0.7578 |
| 2.0 |
1292 |
112 |
9.4 |
955 |
103 |
1174 |
92 |
1559 |
972 |
13.3 |
47.7 |
0.7255 |
| 2.2 |
1402 |
88 |
9.0 |
939 |
131 |
1140 |
114 |
1555 |
1074 |
11.9 |
54.0 |
0.7502 |
| 2.2 |
1376 |
80 |
9.2 |
948 |
172 |
1092 |
122 |
1584 |
1203 |
11.0 |
60.0 |
0.7867 |
| 1.6 |
1272 |
51 |
6.5 |
836 |
131 |
1205 |
116 |
1490 |
1110 |
11.2 |
59.6 |
0.7888 |
| 1.2 |
1197 |
38 |
4.7 |
750 |
89 |
1337 |
96 |
1393 |
949 |
11.2 |
59.2 |
0.7848 |
my_summary <- function(df) {
mean <- sapply(df, function(x) round(mean(x, na.rm = T), 2))
median <- sapply(df, function(x) round(median(x, na.rm = T), 2))
min <- sapply(df, function(x) round(min(x, na.rm = T), 2))
max <- sapply(df, function(x) round(max(x, na.rm = T), 2))
CI <- sapply(df, function(x) paste(round(t.test(x)$conf.int, 2), collapse = " : "))
Std <- sapply(df, function(x) round(sd(x, na.rm = T), 2))
Q1 <- sapply(df, function(x) round(quantile(x, na.rm = T)[c(2)], 2))
Q3 <- sapply(df, function(x) round(quantile(x, na.rm = T)[c(4)], 2))
IQR <- round((Q3 - Q1), 2)
res <- data.frame(Mean=mean, Median=median, Min=min, Max = max,
Q1=Q1, Q3 = Q3, IQR = IQR)
return(res)
}
my_summary(df) %>% knitr::kable()
| CO.GT. |
2.15 |
1.8 |
0.10 |
11.90 |
1.10 |
2.90 |
1.80 |
| PT08.S1.CO. |
1099.83 |
1063.0 |
647.00 |
2040.00 |
937.00 |
1231.00 |
294.00 |
| NMHC.GT. |
218.81 |
150.0 |
7.00 |
1189.00 |
67.00 |
297.00 |
230.00 |
| C6H6.GT. |
10.08 |
8.2 |
0.10 |
63.70 |
4.40 |
14.00 |
9.60 |
| PT08.S2.NMHC. |
939.15 |
909.0 |
383.00 |
2214.00 |
734.50 |
1116.00 |
381.50 |
| NOx.GT. |
246.90 |
180.0 |
2.00 |
1479.00 |
98.00 |
326.00 |
228.00 |
| PT08.S3.NOx. |
835.49 |
806.0 |
322.00 |
2683.00 |
658.00 |
969.50 |
311.50 |
| NO2.GT. |
113.09 |
109.0 |
2.00 |
340.00 |
78.00 |
142.00 |
64.00 |
| PT08.S4.NO2. |
1456.26 |
1463.0 |
551.00 |
2775.00 |
1227.00 |
1674.00 |
447.00 |
| PT08.S5.O3. |
1022.91 |
963.0 |
221.00 |
2523.00 |
731.50 |
1273.50 |
542.00 |
| T |
18.32 |
17.8 |
-1.90 |
44.60 |
11.80 |
24.40 |
12.60 |
| RH |
49.23 |
49.6 |
9.20 |
88.70 |
35.80 |
62.50 |
26.70 |
| AH |
1.03 |
1.0 |
0.18 |
2.23 |
0.74 |
1.31 |
0.57 |
pairs(df)

dfg <- gather(df)
p <- ggplot(dfg, aes(key, value)) +
geom_boxplot(notch=TRUE)
p + facet_wrap(~key, ncol = 5 , scales = "free") +
theme_light()
## Warning: Removed 16701 rows containing non-finite values (stat_boxplot).

corrplot.mixed(cor(df, use="pairwise.complete.obs", method = 'spearman'),
lower = "number",
upper = "circle",
tl.col = "black",
tl.pos = "lt",
sig.level = 0.05,
insig = "blank")

# Function to add correlation coefficients
panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...) {
usr <- par("usr")
on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
Cor <- abs(cor(x, y, method = 'spearman', use="pairwise.complete.obs")) # Remove abs function if desired
txt <- paste0(prefix, format(c(Cor, 0.123456789), digits = digits)[1])
if(missing(cex.cor)) {
cex.cor <- 0.4 / strwidth(txt)
}
text(0.5, 0.5, txt,
cex = 1 + cex.cor * Cor) # Resize the text by level of correlation
}
# Plotting the correlation matrix
pairs(df,
upper.panel = panel.cor, # Correlation panel
lower.panel = panel.smooth) # Smoothed regression lines

#install.packages("GGally")
#library("GGally", verbose = FALSE, quietly = TRUE)
#d <- df[3:15]
#p_ <- GGally::print_if_interactive
#pm <- ggpairs(d,
# columns = colnames(d),
# upper = list(continuous = wrap("cor", size = 10)),
# lower = list(continuous = "smooth"))
#print(pm)
#d <- df[3:15]
#d %>% ggpairs(.,
# lower = list(continuous = wrap("smooth", alpha = 0.3, size=0.1)))
storage <- list()
colpairs <- t(combn(names(df), 2))
for(i in 1:(length(colpairs)/2)){
storage[[i]] <- lm(get(colpairs[i,1]) ~ get(colpairs[i,2]), data=df)
plotname <- paste(colpairs[i,1],"~",colpairs[i,2])
print(summary(storage[[i]]))
print(plot(storage[[i]], which = c(1,2), sub=plotname))
}
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.9862 -0.3917 -0.0342 0.3206 4.7067
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4.285e+00 4.133e-02 -103.7 <2e-16 ***
## get(colpairs[i, 2]) 5.776e-03 3.651e-05 158.2 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6842 on 7342 degrees of freedom
## (2013 observations deleted due to missingness)
## Multiple R-squared: 0.7731, Adjusted R-squared: 0.7731
## F-statistic: 2.502e+04 on 1 and 7342 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.4401 -0.4007 -0.1330 0.2378 3.4060
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.9321504 0.0317875 29.32 <2e-16 ***
## get(colpairs[i, 2]) 0.0060871 0.0001048 58.08 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6406 on 888 degrees of freedom
## (8467 observations deleted due to missingness)
## Multiple R-squared: 0.7916, Adjusted R-squared: 0.7914
## F-statistic: 3374 on 1 and 888 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.6323 -0.2939 -0.0190 0.2411 3.5012
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.2827368 0.0104275 27.11 <2e-16 ***
## get(colpairs[i, 2]) 0.1797413 0.0008219 218.68 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5241 on 7342 degrees of freedom
## (2013 observations deleted due to missingness)
## Multiple R-squared: 0.8669, Adjusted R-squared: 0.8669
## F-statistic: 4.782e+04 on 1 and 7342 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.3053 -0.3638 -0.0290 0.3129 4.6539
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.5625782 0.0249900 -102.5 <2e-16 ***
## get(colpairs[i, 2]) 0.0049539 0.0000254 195.0 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5779 on 7342 degrees of freedom
## (2013 observations deleted due to missingness)
## Multiple R-squared: 0.8382, Adjusted R-squared: 0.8381
## F-statistic: 3.803e+04 on 1 and 7342 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5968 -0.5578 -0.1680 0.4358 5.3424
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.8313575 0.0160993 51.64 <2e-16 ***
## get(colpairs[i, 2]) 0.0053827 0.0000482 111.67 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.8845 on 7259 degrees of freedom
## (2096 observations deleted due to missingness)
## Multiple R-squared: 0.6321, Adjusted R-squared: 0.632
## F-statistic: 1.247e+04 on 1 and 7259 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.6625 -0.6830 -0.1861 0.4399 7.7941
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.385e+00 4.020e-02 133.98 <2e-16 ***
## get(colpairs[i, 2]) -3.937e-03 4.643e-05 -84.81 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.021 on 7342 degrees of freedom
## (2013 observations deleted due to missingness)
## Multiple R-squared: 0.4948, Adjusted R-squared: 0.4948
## F-statistic: 7192 on 1 and 7342 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.4154 -0.5400 -0.1059 0.4111 7.7413
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.1658916 0.0322646 -5.142 2.8e-07 ***
## get(colpairs[i, 2]) 0.0206558 0.0002591 79.727 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.065 on 7256 degrees of freedom
## (2099 observations deleted due to missingness)
## Multiple R-squared: 0.467, Adjusted R-squared: 0.4669
## F-statistic: 6356 on 1 and 7256 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.7518 -0.8131 -0.1553 0.6144 6.8811
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.606e+00 5.520e-02 -29.10 <2e-16 ***
## get(colpairs[i, 2]) 2.586e-03 3.713e-05 69.64 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.115 on 7342 degrees of freedom
## (2013 observations deleted due to missingness)
## Multiple R-squared: 0.3978, Adjusted R-squared: 0.3977
## F-statistic: 4850 on 1 and 7342 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.4728 -0.4533 0.0065 0.4205 5.8419
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.027e+00 2.406e-02 -42.69 <2e-16 ***
## get(colpairs[i, 2]) 3.025e-03 2.149e-05 140.76 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.747 on 7342 degrees of freedom
## (2013 observations deleted due to missingness)
## Multiple R-squared: 0.7296, Adjusted R-squared: 0.7296
## F-statistic: 1.981e+04 on 1 and 7342 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.1101 -1.0687 -0.3368 0.7071 9.7895
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.066032 0.037553 55.016 <2e-16 ***
## get(colpairs[i, 2]) 0.003583 0.001891 1.895 0.0581 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.436 on 7342 degrees of freedom
## (2013 observations deleted due to missingness)
## Multiple R-squared: 0.0004888, Adjusted R-squared: 0.0003527
## F-statistic: 3.591 on 1 and 7342 DF, p-value: 0.05815


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.1595 -1.0713 -0.3170 0.7327 9.6671
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.9322835 0.0499612 38.676 < 2e-16 ***
## get(colpairs[i, 2]) 0.0040242 0.0009595 4.194 2.77e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.435 on 7342 degrees of freedom
## (2013 observations deleted due to missingness)
## Multiple R-squared: 0.00239, Adjusted R-squared: 0.002254
## F-statistic: 17.59 on 1 and 7342 DF, p-value: 2.771e-05


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.1660 -1.0578 -0.3383 0.7075 9.7555
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.95713 0.04469 43.796 < 2e-16 ***
## get(colpairs[i, 2]) 0.17442 0.04187 4.165 3.14e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.435 on 7342 degrees of freedom
## (2013 observations deleted due to missingness)
## Multiple R-squared: 0.002358, Adjusted R-squared: 0.002222
## F-statistic: 17.35 on 1 and 7342 DF, p-value: 3.143e-05


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -354.63 -105.77 -29.07 77.07 593.64
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 985.18952 7.32633 134.47 <2e-16 ***
## get(colpairs[i, 2]) 0.93599 0.02436 38.42 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 149.8 on 885 degrees of freedom
## (8470 observations deleted due to missingness)
## Multiple R-squared: 0.6252, Adjusted R-squared: 0.6247
## F-statistic: 1476 on 1 and 885 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1086.62 -67.84 -8.63 62.75 462.94
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 840.1642 1.8027 466.1 <2e-16 ***
## get(colpairs[i, 2]) 25.7529 0.1438 179.1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 101.6 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.7811, Adjusted R-squared: 0.7811
## F-statistic: 3.207e+04 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -631.97 -65.13 -6.80 61.68 477.18
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.176e+02 3.771e+00 110.7 <2e-16 ***
## get(colpairs[i, 2]) 7.265e-01 3.862e-03 188.1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 97.72 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.7974, Adjusted R-squared: 0.7974
## F-statistic: 3.538e+04 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -433.58 -107.41 -17.04 79.52 805.73
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.293e+02 2.742e+00 339.0 <2e-16 ***
## get(colpairs[i, 2]) 7.549e-01 8.617e-03 87.6 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 152.9 on 7394 degrees of freedom
## (1961 observations deleted due to missingness)
## Multiple R-squared: 0.5093, Adjusted R-squared: 0.5092
## F-statistic: 7674 on 1 and 7394 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -233.53 -97.89 -36.41 67.07 938.66
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.645e+03 4.954e+00 332.1 <2e-16 ***
## get(colpairs[i, 2]) -6.525e-01 5.667e-03 -115.1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 138 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.5959, Adjusted R-squared: 0.5958
## F-statistic: 1.325e+04 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -528.82 -107.88 -22.28 88.82 740.52
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 782.41027 4.98224 157.0 <2e-16 ***
## get(colpairs[i, 2]) 2.94005 0.04089 71.9 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 167.5 on 7391 degrees of freedom
## (1964 observations deleted due to missingness)
## Multiple R-squared: 0.4116, Adjusted R-squared: 0.4115
## F-statistic: 5169 on 1 and 7391 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -349.31 -126.23 -7.06 109.52 636.67
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.763e+02 7.232e+00 65.86 <2e-16 ***
## get(colpairs[i, 2]) 4.282e-01 4.831e-03 88.63 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 158.6 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.4663, Adjusted R-squared: 0.4663
## F-statistic: 7855 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -513.24 -65.35 -3.73 59.03 418.19
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.987e+02 2.758e+00 217.1 <2e-16 ***
## get(colpairs[i, 2]) 4.899e-01 2.513e-03 195.0 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 94.93 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.8088, Adjusted R-squared: 0.8088
## F-statistic: 3.802e+04 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -443.61 -161.69 -39.05 129.09 937.68
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1077.9402 5.2656 204.715 < 2e-16 ***
## get(colpairs[i, 2]) 1.1952 0.2589 4.616 3.97e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 216.8 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.002365, Adjusted R-squared: 0.002254
## F-statistic: 21.31 on 1 and 8989 DF, p-value: 3.971e-06


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -440.30 -163.89 -32.14 132.76 949.84
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1029.1000 6.8551 150.12 <2e-16 ***
## get(colpairs[i, 2]) 1.4367 0.1313 10.94 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 215.7 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.01313, Adjusted R-squared: 0.01302
## F-statistic: 119.6 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -414.12 -159.70 -38.23 129.41 941.40
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1025.229 6.192 165.58 <2e-16 ***
## get(colpairs[i, 2]) 72.747 5.618 12.95 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 215.1 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.01831, Adjusted R-squared: 0.0182
## F-statistic: 167.7 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -352.76 -39.25 4.97 33.55 382.83
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -37.7947 5.0831 -7.435 2.46e-13 ***
## get(colpairs[i, 2]) 25.0434 0.4016 62.360 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 89.01 on 885 degrees of freedom
## (8470 observations deleted due to missingness)
## Multiple R-squared: 0.8146, Adjusted R-squared: 0.8144
## F-statistic: 3889 on 1 and 885 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -220.80 -58.31 -3.36 48.12 508.27
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -410.05223 12.00802 -34.15 <2e-16 ***
## get(colpairs[i, 2]) 0.66633 0.01223 54.49 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 99.07 on 885 degrees of freedom
## (8470 observations deleted due to missingness)
## Multiple R-squared: 0.7703, Adjusted R-squared: 0.7701
## F-statistic: 2969 on 1 and 885 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -361.22 -62.03 -6.19 43.48 535.95
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -63.60867 8.10061 -7.852 1.19e-14 ***
## get(colpairs[i, 2]) 2.04177 0.04949 41.255 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 119.9 on 875 degrees of freedom
## (8480 observations deleted due to missingness)
## Multiple R-squared: 0.6605, Adjusted R-squared: 0.6601
## F-statistic: 1702 on 1 and 875 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -219.48 -81.96 -38.43 55.53 681.88
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 782.36594 16.25826 48.12 <2e-16 ***
## get(colpairs[i, 2]) -0.57105 0.01585 -36.03 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 131.6 on 885 degrees of freedom
## (8470 observations deleted due to missingness)
## Multiple R-squared: 0.5946, Adjusted R-squared: 0.5942
## F-statistic: 1298 on 1 and 885 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -307.46 -82.57 -17.80 58.88 781.77
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -243.8348 15.5529 -15.68 <2e-16 ***
## get(colpairs[i, 2]) 4.7285 0.1491 31.71 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 140.4 on 875 degrees of freedom
## (8480 observations deleted due to missingness)
## Multiple R-squared: 0.5346, Adjusted R-squared: 0.5341
## F-statistic: 1005 on 1 and 875 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -314.79 -65.58 -7.29 54.71 466.55
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -702.50721 19.26607 -36.46 <2e-16 ***
## get(colpairs[i, 2]) 0.58257 0.01197 48.68 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 107.8 on 885 degrees of freedom
## (8470 observations deleted due to missingness)
## Multiple R-squared: 0.7281, Adjusted R-squared: 0.7278
## F-statistic: 2369 on 1 and 885 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -328.31 -90.62 -7.30 68.46 555.40
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -186.44508 12.24042 -15.23 <2e-16 ***
## get(colpairs[i, 2]) 0.39593 0.01114 35.53 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 132.7 on 885 degrees of freedom
## (8470 observations deleted due to missingness)
## Multiple R-squared: 0.5879, Adjusted R-squared: 0.5874
## F-statistic: 1262 on 1 and 885 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -308.30 -120.86 -57.83 64.72 935.74
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -39.286 21.348 -1.84 0.0661 .
## get(colpairs[i, 2]) 16.813 1.328 12.66 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 190.2 on 885 degrees of freedom
## (8470 observations deleted due to missingness)
## Multiple R-squared: 0.1533, Adjusted R-squared: 0.1524
## F-statistic: 160.3 on 1 and 885 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -258.64 -134.25 -78.97 66.91 965.13
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 347.6661 23.2604 14.947 < 2e-16 ***
## get(colpairs[i, 2]) -2.5899 0.4463 -5.803 9.07e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 202.9 on 885 degrees of freedom
## (8470 observations deleted due to missingness)
## Multiple R-squared: 0.03665, Adjusted R-squared: 0.03557
## F-statistic: 33.67 on 1 and 885 DF, p-value: 9.073e-09


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -326.68 -138.36 -64.42 76.92 936.65
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -42.77 32.07 -1.334 0.183
## get(colpairs[i, 2]) 314.23 37.71 8.333 2.98e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 199.1 on 885 degrees of freedom
## (8470 observations deleted due to missingness)
## Multiple R-squared: 0.07276, Adjusted R-squared: 0.07171
## F-statistic: 69.44 on 1 and 885 DF, p-value: 2.98e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.2077 -0.9919 -0.5052 0.5355 18.6662
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.566e+01 5.438e-02 -288.1 <2e-16 ***
## get(colpairs[i, 2]) 2.742e-02 5.570e-05 492.2 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.409 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.9642, Adjusted R-squared: 0.9642
## F-statistic: 2.423e+05 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -12.926 -3.974 -1.115 2.840 38.846
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.0861758 0.0927714 44.05 <2e-16 ***
## get(colpairs[i, 2]) 0.0259280 0.0002916 88.92 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5.174 on 7394 degrees of freedom
## (1961 observations deleted due to missingness)
## Multiple R-squared: 0.5167, Adjusted R-squared: 0.5167
## F-statistic: 7906 on 1 and 7394 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.972 -3.557 -0.886 2.181 44.557
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 27.9147492 0.1811202 154.1 <2e-16 ***
## get(colpairs[i, 2]) -0.0213426 0.0002072 -103.0 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5.046 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.5413, Adjusted R-squared: 0.5413
## F-statistic: 1.061e+04 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -18.063 -3.454 -0.595 2.468 43.171
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.403719 0.174719 -2.311 0.0209 *
## get(colpairs[i, 2]) 0.096021 0.001434 66.960 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5.872 on 7391 degrees of freedom
## (1964 observations deleted due to missingness)
## Multiple R-squared: 0.3776, Adjusted R-squared: 0.3775
## F-statistic: 4484 on 1 and 7391 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.479 -3.644 -0.564 2.959 50.771
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -13.912234 0.218500 -63.67 <2e-16 ***
## get(colpairs[i, 2]) 0.016477 0.000146 112.88 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.792 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.5863, Adjusted R-squared: 0.5863
## F-statistic: 1.274e+04 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -16.496 -2.279 -0.029 2.088 32.770
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6.472e+00 1.084e-01 -59.73 <2e-16 ***
## get(colpairs[i, 2]) 1.618e-02 9.871e-05 163.96 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.729 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.7494, Adjusted R-squared: 0.7494
## F-statistic: 2.688e+04 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.859 -5.324 -1.938 3.482 55.650
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.009050 0.177302 39.53 <2e-16 ***
## get(colpairs[i, 2]) 0.167818 0.008719 19.25 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.301 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.03958, Adjusted R-squared: 0.03948
## F-statistic: 370.5 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.194 -5.538 -1.875 3.735 53.685
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 11.389555 0.236365 48.186 < 2e-16 ***
## get(colpairs[i, 2]) -0.026535 0.004529 -5.859 4.82e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.436 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.003805, Adjusted R-squared: 0.003694
## F-statistic: 34.33 on 1 and 8989 DF, p-value: 4.817e-09


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -11.831 -5.517 -1.813 3.747 55.260
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.9051 0.2114 32.66 <2e-16 ***
## get(colpairs[i, 2]) 3.0989 0.1918 16.16 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.344 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.02821, Adjusted R-squared: 0.02811
## F-statistic: 261 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -444.20 -147.63 -27.48 128.70 759.15
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 731.23110 3.37827 216.45 <2e-16 ***
## get(colpairs[i, 2]) 0.90623 0.01062 85.34 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 188.4 on 7394 degrees of freedom
## (1961 observations deleted due to missingness)
## Multiple R-squared: 0.4962, Adjusted R-squared: 0.4962
## F-statistic: 7283 on 1 and 7394 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -342.62 -119.53 -17.03 91.38 1339.44
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.631e+03 5.789e+00 281.7 <2e-16 ***
## get(colpairs[i, 2]) -8.278e-01 6.623e-03 -125.0 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 161.3 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.6347, Adjusted R-squared: 0.6347
## F-statistic: 1.562e+04 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -639.27 -141.33 -1.33 118.24 959.66
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 546.74147 6.02758 90.71 <2e-16 ***
## get(colpairs[i, 2]) 3.60170 0.04947 72.80 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 202.6 on 7391 degrees of freedom
## (1964 observations deleted due to missingness)
## Multiple R-squared: 0.4176, Adjusted R-squared: 0.4176
## F-statistic: 5300 on 1 and 7391 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -413.19 -120.99 -7.98 110.67 1171.37
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 66.774964 7.656011 8.722 <2e-16 ***
## get(colpairs[i, 2]) 0.599052 0.005115 117.122 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 167.9 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.6041, Adjusted R-squared: 0.6041
## F-statistic: 1.372e+04 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -586.32 -84.19 -1.64 86.68 515.32
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.360e+02 3.674e+00 91.45 <2e-16 ***
## get(colpairs[i, 2]) 5.896e-01 3.347e-03 176.17 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 126.5 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.7754, Adjusted R-squared: 0.7754
## F-statistic: 3.104e+04 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -522.32 -195.35 -36.38 159.72 1363.21
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 805.5753 6.2884 128.10 <2e-16 ***
## get(colpairs[i, 2]) 7.2922 0.3092 23.58 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 259 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.05826, Adjusted R-squared: 0.05816
## F-statistic: 556.1 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -565.49 -200.10 -31.45 170.34 1278.42
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1007.7190 8.4474 119.294 <2e-16 ***
## get(colpairs[i, 2]) -1.3926 0.1619 -8.604 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 265.8 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.008169, Adjusted R-squared: 0.008058
## F-statistic: 74.03 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -553.0 -201.8 -30.7 172.2 1340.3
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 812.478 7.546 107.67 <2e-16 ***
## get(colpairs[i, 2]) 123.522 6.847 18.04 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 262.1 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.03494, Adjusted R-squared: 0.03484
## F-statistic: 325.5 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -352.33 -101.93 -33.48 60.10 990.23
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 676.386843 6.089877 111.07 <2e-16 ***
## get(colpairs[i, 2]) -0.526598 0.007052 -74.68 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 155.8 on 7394 degrees of freedom
## (1961 observations deleted due to missingness)
## Multiple R-squared: 0.43, Adjusted R-squared: 0.4299
## F-statistic: 5577 on 1 and 7394 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -340.20 -85.80 -24.77 49.40 852.61
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -133.11223 3.98592 -33.4 <2e-16 ***
## get(colpairs[i, 2]) 3.36055 0.03241 103.7 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 137.7 on 7713 degrees of freedom
## (1642 observations deleted due to missingness)
## Multiple R-squared: 0.5823, Adjusted R-squared: 0.5823
## F-statistic: 1.075e+04 on 1 and 7713 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -293.56 -148.43 -62.83 93.09 1125.11
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 44.098034 9.863014 4.471 7.9e-06 ***
## get(colpairs[i, 2]) 0.136414 0.006599 20.671 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 200.6 on 7394 degrees of freedom
## (1961 observations deleted due to missingness)
## Multiple R-squared: 0.05463, Adjusted R-squared: 0.0545
## F-statistic: 427.3 on 1 and 7394 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -497.10 -82.29 -7.03 74.50 765.82
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.762e+02 4.091e+00 -43.08 <2e-16 ***
## get(colpairs[i, 2]) 4.001e-01 3.647e-03 109.71 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 127.3 on 7394 degrees of freedom
## (1961 observations deleted due to missingness)
## Multiple R-squared: 0.6194, Adjusted R-squared: 0.6194
## F-statistic: 1.204e+04 on 1 and 7394 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -324.87 -135.07 -51.35 77.40 1203.63
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 353.2476 5.1580 68.48 <2e-16 ***
## get(colpairs[i, 2]) -6.1805 0.2566 -24.08 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 198.7 on 7394 degrees of freedom
## (1961 observations deleted due to missingness)
## Multiple R-squared: 0.07273, Adjusted R-squared: 0.0726
## F-statistic: 579.9 on 1 and 7394 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -313.59 -139.80 -52.18 81.90 1218.22
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 115.0759 6.9296 16.61 <2e-16 ***
## get(colpairs[i, 2]) 2.6064 0.1337 19.49 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 201.2 on 7394 degrees of freedom
## (1961 observations deleted due to missingness)
## Multiple R-squared: 0.04886, Adjusted R-squared: 0.04873
## F-statistic: 379.8 on 1 and 7394 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -271.37 -139.51 -64.63 75.71 1223.02
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 318.126 6.311 50.41 <2e-16 ***
## get(colpairs[i, 2]) -76.329 5.878 -12.99 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 204 on 7394 degrees of freedom
## (1961 observations deleted due to missingness)
## Multiple R-squared: 0.0223, Adjusted R-squared: 0.02217
## F-statistic: 168.6 on 1 and 7394 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -616.5 -121.5 -14.2 100.5 1752.1
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1219.06233 5.79615 210.32 <2e-16 ***
## get(colpairs[i, 2]) -3.51766 0.04757 -73.94 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 194.8 on 7391 degrees of freedom
## (1964 observations deleted due to missingness)
## Multiple R-squared: 0.4252, Adjusted R-squared: 0.4251
## F-statistic: 5468 on 1 and 7391 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -535.55 -155.26 -4.47 114.46 1600.95
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.417e+03 9.869e+00 143.60 <2e-16 ***
## get(colpairs[i, 2]) -3.994e-01 6.593e-03 -60.59 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 216.4 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.2899, Adjusted R-squared: 0.2899
## F-statistic: 3671 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -371.02 -100.14 -23.56 66.56 1651.62
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.361e+03 4.511e+00 301.6 <2e-16 ***
## get(colpairs[i, 2]) -5.134e-01 4.109e-03 -124.9 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 155.3 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.6345, Adjusted R-squared: 0.6345
## F-statistic: 1.561e+04 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -535.46 -174.68 -20.25 135.14 1818.74
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 912.7862 6.1708 147.9 <2e-16 ***
## get(colpairs[i, 2]) -4.2195 0.3034 -13.9 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 254.1 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.02106, Adjusted R-squared: 0.02095
## F-statistic: 193.4 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -505.61 -177.67 -32.81 134.14 1838.05
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 876.9228 8.1506 107.590 < 2e-16 ***
## get(colpairs[i, 2]) -0.8415 0.1562 -5.388 7.3e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 256.4 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.003219, Adjusted R-squared: 0.003108
## F-statistic: 29.03 on 1 and 8989 DF, p-value: 7.298e-08


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -545.34 -172.09 -24.42 132.68 1772.31
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 986.819 7.191 137.22 <2e-16 ***
## get(colpairs[i, 2]) -147.559 6.525 -22.61 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 249.8 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.05383, Adjusted R-squared: 0.05373
## F-statistic: 511.4 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -117.618 -34.141 -5.449 27.357 225.562
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 81.360166 2.312861 35.18 <2e-16 ***
## get(colpairs[i, 2]) 0.021202 0.001548 13.70 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 47.04 on 7391 degrees of freedom
## (1964 observations deleted due to missingness)
## Multiple R-squared: 0.02476, Adjusted R-squared: 0.02463
## F-statistic: 187.7 on 1 and 7391 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -157.569 -23.350 -3.435 18.986 171.324
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.525e+01 1.081e+00 23.36 <2e-16 ***
## get(colpairs[i, 2]) 8.310e-02 9.638e-04 86.22 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 33.63 on 7391 degrees of freedom
## (1964 observations deleted due to missingness)
## Multiple R-squared: 0.5014, Adjusted R-squared: 0.5014
## F-statistic: 7434 on 1 and 7391 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -112.479 -34.500 -3.617 28.880 211.513
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 129.87697 1.21503 106.89 <2e-16 ***
## get(colpairs[i, 2]) -0.98703 0.06047 -16.32 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 46.8 on 7391 degrees of freedom
## (1964 observations deleted due to missingness)
## Multiple R-squared: 0.03479, Adjusted R-squared: 0.03466
## F-statistic: 266.4 on 1 and 7391 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -109.839 -34.689 -4.185 27.838 218.588
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 124.32941 1.63396 76.091 < 2e-16 ***
## get(colpairs[i, 2]) -0.24980 0.03153 -7.922 2.68e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 47.43 on 7391 degrees of freedom
## (1964 observations deleted due to missingness)
## Multiple R-squared: 0.00842, Adjusted R-squared: 0.008286
## F-statistic: 62.76 on 1 and 7391 DF, p-value: 2.679e-15


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -118.411 -31.878 -2.479 27.240 199.024
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 151.468 1.388 109.11 <2e-16 ***
## get(colpairs[i, 2]) -39.530 1.293 -30.57 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 44.88 on 7391 degrees of freedom
## (1964 observations deleted due to missingness)
## Multiple R-squared: 0.1122, Adjusted R-squared: 0.1121
## F-statistic: 934.4 on 1 and 7391 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -797.55 -216.07 51.03 214.61 937.88
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.309e+02 8.114e+00 114.73 <2e-16 ***
## get(colpairs[i, 2]) 5.136e-01 7.391e-03 69.49 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 279.3 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.3495, Adjusted R-squared: 0.3494
## F-statistic: 4829 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -817.28 -194.66 -32.87 154.32 1322.73
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1053.2541 6.9584 151.4 <2e-16 ***
## get(colpairs[i, 2]) 22.0010 0.3422 64.3 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 286.5 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.315, Adjusted R-squared: 0.3149
## F-statistic: 4134 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -912.82 -225.02 6.64 213.77 1326.63
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1487.9478 10.9996 135.273 < 2e-16 ***
## get(colpairs[i, 2]) -0.6435 0.2108 -3.053 0.00227 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 346 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.001036, Adjusted R-squared: 0.0009249
## F-statistic: 9.323 on 1 and 8989 DF, p-value: 0.00227


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -574.4 -207.4 -42.3 157.8 1280.9
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 902.663 7.743 116.58 <2e-16 ***
## get(colpairs[i, 2]) 539.820 7.025 76.84 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 269 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.3964, Adjusted R-squared: 0.3964
## F-statistic: 5904 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -824.49 -289.77 -61.83 252.18 1498.28
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1045.3627 9.6736 108.063 < 2e-16 ***
## get(colpairs[i, 2]) -1.2259 0.4757 -2.577 0.00998 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 398.4 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.0007383, Adjusted R-squared: 0.0006272
## F-statistic: 6.642 on 1 and 8989 DF, p-value: 0.009978


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -783.81 -294.57 -59.11 253.62 1553.69
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 881.3376 12.5678 70.13 <2e-16 ***
## get(colpairs[i, 2]) 2.8754 0.2408 11.94 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 395.4 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.01561, Adjusted R-squared: 0.0155
## F-statistic: 142.6 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -746.55 -293.77 -61.36 250.58 1527.53
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 951.31 11.44 83.136 < 2e-16 ***
## get(colpairs[i, 2]) 69.82 10.38 6.725 1.87e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 397.5 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.005006, Adjusted R-squared: 0.004895
## F-statistic: 45.22 on 1 and 8989 DF, p-value: 1.865e-11


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -24.0826 -4.3165 0.6476 5.7036 15.4709
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 32.847499 0.228984 143.45 <2e-16 ***
## get(colpairs[i, 2]) -0.295113 0.004387 -67.26 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.204 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.3348, Adjusted R-squared: 0.3347
## F-statistic: 4524 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -12.430 -5.009 -1.599 3.540 27.503
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.5947 0.1918 18.74 <2e-16 ***
## get(colpairs[i, 2]) 14.3566 0.1740 82.49 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.663 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.4309, Adjusted R-squared: 0.4308
## F-statistic: 6805 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
##
## Call:
## lm(formula = get(colpairs[i, 1]) ~ get(colpairs[i, 2]), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -38.018 -12.559 0.166 12.735 40.165
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 41.8471 0.4914 85.15 <2e-16 ***
## get(colpairs[i, 2]) 7.2032 0.4459 16.16 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 17.07 on 8989 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.02821, Adjusted R-squared: 0.02811
## F-statistic: 261 on 1 and 8989 DF, p-value: < 2.2e-16


## NULL
#lm <- lm(PT08.S2.NMHC. ~ PT08.S1.CO., data=df)
#summary(lm)
#plot(lm, which = c(1,2))
set.seed(88)
data <- df
sample <- sample.int(n = nrow(data), size = floor(.75*nrow(data)))
train <- data[sample, ]
test <- data[-sample, ]
new_mod <- lm(data = train, CO.GT. ~ C6H6.GT.)
summary(new_mod)
##
## Call:
## lm(formula = CO.GT. ~ C6H6.GT., data = train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.6620 -0.2941 -0.0172 0.2403 3.4935
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.2780315 0.0120911 23.0 <2e-16 ***
## C6H6.GT. 0.1802813 0.0009595 187.9 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5282 on 5517 degrees of freedom
## (1498 observations deleted due to missingness)
## Multiple R-squared: 0.8648, Adjusted R-squared: 0.8648
## F-statistic: 3.53e+04 on 1 and 5517 DF, p-value: < 2.2e-16
p <- train %>%
ggplot(aes(x = C6H6.GT., y = CO.GT.)) +
geom_point() +
geom_smooth(method = "lm")
print(p)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1498 rows containing non-finite values (stat_smooth).
## Warning: Removed 1498 rows containing missing values (geom_point).

pred <- predict(new_mod, newdata = test)
head(pred)
## 2 11 25 30 31 34
## 1.9726759 0.5123972 4.0278830 0.7467629 1.3416913 0.6205660
test$CO.GT._pred <- pred
head(test[c("CO.GT.","CO.GT._pred")])
## CO.GT. CO.GT._pred
## 2 2.0 1.9726759
## 11 NA 0.5123972
## 25 4.8 4.0278830
## 30 1.0 0.7467629
## 31 1.7 1.3416913
## 34 0.8 0.6205660
df_train <- data.frame(key='train', "CO.GT."=train$CO.GT., "C6H6.GT."=train$C6H6.GT.)
df_test <- data.frame(key='test', "CO.GT."=test$CO.GT., "C6H6.GT."=test$C6H6.GT.)
df_predicted <-data.frame(key='predicted', "CO.GT."=test$CO.GT._pred, "C6H6.GT."=test$C6H6.GT.)
long <- rbind(df_train, df_test, df_predicted)
head(long)
## key CO.GT. C6H6.GT.
## 1 train 1.0 NA
## 2 train 2.9 17.4
## 3 train 1.4 6.1
## 4 train 1.0 8.2
## 5 train NA 17.8
## 6 train 0.5 1.2
p <- long %>%
ggplot(aes(x = C6H6.GT., y = CO.GT., col=key)) +
geom_point() +
geom_smooth(method = "lm", se=F)
R2 <- round(summary(new_mod)$r.squared*100,2)
pvalue <- summary(new_mod)$coefficients[2,4]
p + ggtitle(paste("R^2 :", R2, ", p-value : ", pvalue))
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 2105 rows containing non-finite values (stat_smooth).
## Warning: Removed 2105 rows containing missing values (geom_point).
# MULTIPLE LINEAR REGRESSION
CO.GT. - True hourly averaged concentration CO in mg/m^3 (reference analyzer) C6H6.GT. - True hourly averaged Benzene concentration in microg/m^3 (reference analyzer) NO2.GT. - True hourly averaged NO2 concentration in microg/m^3 (reference analyzer) PT08.S4.NO2. - PT08.S4 (tungsten oxide) hourly averaged sensor response (nominally NO2 targeted)
new_mod10 <- lm(data = train, CO.GT. ~ C6H6.GT.)
summary(new_mod10)
##
## Call:
## lm(formula = CO.GT. ~ C6H6.GT., data = train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.6620 -0.2941 -0.0172 0.2403 3.4935
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.2780315 0.0120911 23.0 <2e-16 ***
## C6H6.GT. 0.1802813 0.0009595 187.9 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5282 on 5517 degrees of freedom
## (1498 observations deleted due to missingness)
## Multiple R-squared: 0.8648, Adjusted R-squared: 0.8648
## F-statistic: 3.53e+04 on 1 and 5517 DF, p-value: < 2.2e-16
new_mod11 <- lm(data = train, CO.GT. ~ NO2.GT.)
summary(new_mod11)
##
## Call:
## lm(formula = CO.GT. ~ NO2.GT., data = train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.4174 -0.5343 -0.1028 0.4206 7.7430
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.1802749 0.0372633 -4.838 1.35e-06 ***
## NO2.GT. 0.0207223 0.0003002 69.019 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.064 on 5447 degrees of freedom
## (1568 observations deleted due to missingness)
## Multiple R-squared: 0.4665, Adjusted R-squared: 0.4664
## F-statistic: 4764 on 1 and 5447 DF, p-value: < 2.2e-16
new_mod12 <- lm(data = train, CO.GT. ~ PT08.S4.NO2.)
summary(new_mod12)
##
## Call:
## lm(formula = CO.GT. ~ PT08.S4.NO2., data = train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.7441 -0.8144 -0.1587 0.6056 6.8877
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.617e+00 6.363e-02 -25.40 <2e-16 ***
## PT08.S4.NO2. 2.587e-03 4.287e-05 60.35 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.115 on 5517 degrees of freedom
## (1498 observations deleted due to missingness)
## Multiple R-squared: 0.3977, Adjusted R-squared: 0.3976
## F-statistic: 3642 on 1 and 5517 DF, p-value: < 2.2e-16
new_mod2 <- lm(data = train, CO.GT. ~ C6H6.GT. + NO2.GT.)
print(summary(new_mod2))
##
## Call:
## lm(formula = CO.GT. ~ C6H6.GT. + NO2.GT., data = train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.1150 -0.2272 0.0055 0.2166 3.2683
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.1130779 0.0177646 -6.365 2.12e-10 ***
## C6H6.GT. 0.1593627 0.0011564 137.814 < 2e-16 ***
## NO2.GT. 0.0053978 0.0001816 29.724 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4937 on 5213 degrees of freedom
## (1801 observations deleted due to missingness)
## Multiple R-squared: 0.8829, Adjusted R-squared: 0.8828
## F-statistic: 1.965e+04 on 2 and 5213 DF, p-value: < 2.2e-16
print(plot(new_mod2))




## NULL
pred2 <- predict(new_mod2, newdata = test)
test$CO.GT._pred2 <- pred2
head(test[c("CO.GT.","CO.GT._pred2")])
## CO.GT. CO.GT._pred2
## 2 2.0 1.8815262
## 11 NA 0.2776178
## 25 4.8 4.0167292
## 30 1.0 0.5873469
## 31 1.7 1.3507456
## 34 0.8 NA
print(
paste0(
"R^2: ", round(summary(new_mod2)$r.squared*100,2),
", pvalue: C6H6.GT.=", summary(new_mod2)$coefficients[2,4], "; NO2.GT.=", summary(new_mod2)$coefficients[3,4]
)
)
## [1] "R^2: 88.29, pvalue: C6H6.GT.=0; NO2.GT.=1.74020621918569e-179"
new_mod3 <- lm(data = train, CO.GT. ~ C6H6.GT. + NO2.GT. + PT08.S4.NO2.)
print(summary(new_mod3))
##
## Call:
## lm(formula = CO.GT. ~ C6H6.GT. + NO2.GT. + PT08.S4.NO2., data = train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.8376 -0.2177 0.0018 0.2077 3.2123
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.445e-01 5.388e-02 6.394 1.76e-10 ***
## C6H6.GT. 1.766e-01 2.233e-03 79.085 < 2e-16 ***
## NO2.GT. 4.123e-03 2.293e-04 17.979 < 2e-16 ***
## PT08.S4.NO2. -3.398e-04 3.781e-05 -8.988 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4899 on 5212 degrees of freedom
## (1801 observations deleted due to missingness)
## Multiple R-squared: 0.8847, Adjusted R-squared: 0.8846
## F-statistic: 1.333e+04 on 3 and 5212 DF, p-value: < 2.2e-16
print(plot(new_mod3))




## NULL
pred3 <- predict(new_mod3, newdata = test)
test$CO.GT._pred3 <- pred3
head(test[c("CO.GT.","CO.GT._pred3")])
## CO.GT. CO.GT._pred3
## 2 2.0 1.8538046
## 11 NA 0.3074181
## 25 4.8 3.9319593
## 30 1.0 0.5966163
## 31 1.7 1.3189371
## 34 0.8 NA
print(
paste0(
"R^2: ", round(summary(new_mod3)$r.squared*100,2),
", pvalue: C6H6.GT.=", summary(new_mod3)$coefficients[2,4],
"; NO2.GT.=", summary(new_mod3)$coefficients[3,4],
"; PT08.S4.NO2=", summary(new_mod3)$coefficients[4,4]
)
)
## [1] "R^2: 88.47, pvalue: C6H6.GT.=0; NO2.GT.=3.58242089385094e-70; PT08.S4.NO2=3.46944725173484e-19"